package com.example.shixi.controller;

import com.example.shixi.domain.BlogArticleType;
import com.example.shixi.domain.SysOperLog;
import com.example.shixi.service.ArticleTypeService;
import com.example.shixi.service.LogService;
import com.example.shixi.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/type")
public class ArticleTypeController {
    @Autowired
    private LogService logService;
    @Autowired
    private ArticleTypeService articleTypeService;
    @GetMapping("/query/{pageNum}/{pageSize}")
    public JSONResult query(BlogArticleType bat, @PathVariable Integer pageNum, @PathVariable Integer pageSize){
        logService.add(bat.getUpdateUserName(), "查看文章类型列表");
        return articleTypeService.query(bat,pageNum,pageSize);
    }
    @PostMapping("/add")
    public JSONResult add(@RequestBody BlogArticleType bat,String updateUserName){
        logService.add(updateUserName,"增加文章类型");
        return articleTypeService.add(bat);
    }
    @DeleteMapping("/del/{id}")
    public JSONResult del(@PathVariable Long id,String updateUserName){
        logService.add(updateUserName,"删除文章类型");
        return articleTypeService.del(id);
    }
    @PutMapping("/update")
    public JSONResult update(@RequestBody BlogArticleType bat,String updateUserName){
        logService.add(updateUserName,"编辑文章类型");
        return articleTypeService.update(bat);
    }


}
